/**
 * 表单 Fields 类
 * @class Fields
 */
export default class Fields {
  constructor(obj) {
    this.name = obj.name // 字段名
    this.defaultValue = obj.defaultValue // 字段默认值
    this.fieldName = obj.fieldName // 字段
    this.formType = obj.formType // 字段类型
    this.inputTips = obj.inputTips || null // 输入提示
    this.isNull = obj.isNull || 0 // 非空  1 必填 0 非必填
    this.isUnique = obj.isUnique || 0 // 是否唯一  1 是  0 否
    this.setting = obj.setting || [] // 选项
    this.value = obj.value || '' // 字段值
    this.fieldType = obj.fieldType || 1
    this.disabled = obj.disabled || false
    this.precisions = obj.precisions || null // 精度
    if (obj.maxSelected) {
      this.maxSelected = obj.maxSelected
    }
    if (obj.maxlength) {
      this.maxlength = obj.maxlength
    }
		
		Object.keys(obj).forEach(key => {
			if (!this.hasOwnProperty(key)) {
				this[key] = obj[key]
			}
		})
  }
}


const constantTypes = {
  text: '单行文本',
  textarea: '多行文本',
  select: '下拉',
  radio: '单选',
  checkbox: '多选',
  number: '数字',
  floatnumber: '货币',
  mobile: '手机',
  email: '邮箱',
  date: '日期',
  datetime: '日期时间',
  file: '附件',
}

const asyncTypes = {
  address: '地址',
  user: '用户',
  structure: '部门',
  customer: '客户',
  contacts: '联系人',
  business: '商机',
  category: '产品类别',
  business_type: '商机状态组',
  business_status: '商机阶段',
  form: '表格',
}

const types = {
  text: '点击填写',
  email: '点击填写',
  mobile: '点击填写',
  phone: '点击填写',
  url: '点击填写',
  textarea: '点击填写',
  image: null,
  select: '点击选择',
  address: '点击选择',
  time: '点击选择',
}